package com.czy.security.service.impl;

import com.czy.security.entity.Admin;
import com.czy.security.service.AdminService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @作者:褚
 * @工程名:spring_security
 * @方法:AdminServiceImpl
 * @创建时间:2022/4/12 14:52
 */
@Service
public class AdminServiceImpl implements AdminService {
    private List<Admin> adminList = new ArrayList<>();
    public AdminServiceImpl(){
        adminList.add(new Admin(1,"zhangsan","1111","北京"));
        adminList.add(new Admin(2,"lisi","2222","武汉"));
        adminList.add(new Admin(3,"wangwu","3333","长沙"));
        adminList.add(new Admin(4,"zhaoliu","4444","大理"));
    }
    @Override
    public Admin login(String username) {
        for (Admin admin:adminList){
            if (username.equals(admin.getAname())){
                return admin;
            }
        }
        return null;
    }
}
